package com.cskaoyan.dbutils.resultsethandler;

import com.cskaoyan.connectionpool.DruidUtils;
import com.cskaoyan.dbutils.City;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class BeanHandlerDemo {

    public static void main(String[] args) throws SQLException {

        // 创建一个QueryRunner对象
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        // 执行SQL ResultSet
        City city = queryRunner.query("select * from city where id = ?",new BeanHandler<>(City.class),1);


        System.out.println(city);

    }
}
